﻿<%@ Page Language="C#" AutoEventWireup="true"  MasterPageFile="~/Main.Master"  CodeBehind="fact_cost_import.aspx.cs" Inherits="BSC.fact_cost_import" %>
<%@ Import Namespace="Ext.Net.Utilities" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <ext:XScript ID="XScript1" runat="server">
        <script type="text/javascript">
            var checkType=function()
            {
                var arr=#{FileUploadField1}.getValue().split(".");
                
                if(arr[arr.length-1]!="xls")
                {
                    Ext.Msg.show({ 
                        title   : 'Error', 
                        msg     : 'Vui lòng chọn file excel', 
                        minWidth: 200, 
                        modal   : true, 
                        icon    : Ext.Msg.ERROR, 
                        buttons : Ext.Msg.OK 
                    });
                    #{btnUpload}.setDisabled(true);
                }
                else
                {
                    #{btnUpload}.setDisabled(false);
                }
                
            }
        </script>
    </ext:XScript>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">
    
    <ext:FormPanel ID="frmCostUpload" runat="server" Layout="AbsoluteLayout" Border="false"
       FileUpload="true" PaddingSummary="10px 10px 10px 10px" BodyStyle="background:#dfe8f6" >
        <Items>
             
            <ext:FileUploadField ID="FileUploadField1" runat="server" 
                Width="350" Icon="Attach" EmptyText="Chọn file..." LabelWidth="10">
                <Listeners>
                    <FileSelected Handler="checkType()" />
                </Listeners>
            </ext:FileUploadField>
           
            
  
        </Items>           
        <BottomBar>
            <ext:StatusBar ID="StatusBar1" runat="Server">
                <Items>
                    <ext:Button ID="btnUpload"  Disabled="true" runat="Server" Text="Import" Icon="Disk">
                        <DirectEvents>
                            <Click OnEvent="Upload" Before="return #{frmCostUpload}.getForm().isValid()"
                                Success="" Failure="SRResultInfo(0,'Có lỗi phát sinh trong quá trình import')" Complete="#{Store1}.reload()">
                                <EventMask Msg="Đang xử lý dữ liệu" ShowMask="true" />
                            </Click>
                        </DirectEvents>
                        
                    </ext:Button>
                </Items>
            </ext:StatusBar>
        </BottomBar>
    </ext:FormPanel>
    <%--<asp:ObjectDataSource 
            ID="ObjectDataSource1" 
            runat="server" 
            SelectMethod="GetAll"
            TypeName="ObjectLayer.fact_costs_revenuesBO" 
            />--%>
    <ext:GridPanel ID="grid"  runat="server" Height="400" Frame="true">
                <Store>
                    <ext:Store ID="Store1" runat="server" OnRefreshData="refresh">
                        <Reader>
                            <ext:JsonReader IDProperty="cost_code">
                                <Fields>
                                    <ext:RecordField Name="criteria_name" />
                                    <ext:RecordField Name="cost_code" />
                                    <ext:RecordField Name="cost" />
                                </Fields>
                            </ext:JsonReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        
                        <ext:Column ColumnID="cost_code" Header="Mã HT" Width="150" DataIndex="cost_code">
                        </ext:Column>
                        <ext:Column ColumnID="criteria_name" DataIndex="cost" Header="Tiêu chí" Width="200" />
                        <%--<ext:Column DataIndex="name" Header="Tiêu chí" Width="150" />--%>
                        <ext:Column ColumnID="cost" DataIndex="cost" Header="Giá trị" Width="150" />
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
            </SelectionModel>
     </ext:GridPanel>
</asp:Content>

